//package io.xiyou.user.controller;
//
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.kafka.core.KafkaTemplate;
//import org.springframework.kafka.support.SendResult;
//import org.springframework.util.concurrent.ListenableFuture;
//import org.springframework.util.concurrent.ListenableFutureCallback;
//import org.springframework.web.bind.annotation.GetMapping;
//import org.springframework.web.bind.annotation.PathVariable;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//
///**
// * @ClassName：KafkaSendMessageController
// * @Author：西柚
// * @Date：2021/11/2 6:33 下午
// * @Versiion：1.0
// */
//@Slf4j
//@RestController
//@RequestMapping("/kafka")
//public class KafkaSendMessageController {
//
//    @Autowired
//    private KafkaTemplate<String, String> kafkaTemplate;
//
//    @Value("${spring.kafka.topic-name}")
//    private String topicName;
//
//    @GetMapping("send/{message}")
//    public void send(@PathVariable String message) {
////        this.kafkaTemplate.send(topicName, message);
//
//        ListenableFuture<SendResult<String, String>> future = this.kafkaTemplate.send(topicName, message);
//        future.addCallback(new ListenableFutureCallback<SendResult<String, String>>() {
//            @Override
//            public void onSuccess(SendResult<String, String> result) {
//                log.info("成功发送消息：{}，offset=[{}]", message, result.getRecordMetadata().offset());
//            }
//
//            @Override
//            public void onFailure(Throwable ex) {
//                log.error("消息：{} 发送失败，原因：{}", message, ex.getMessage());
//            }
//        });
//
//    }
//
//}
